<?php
require_once "../class/fenajax.class.php";
include "../dyn/connexion.php";

$f = newFen(__FILE__,"Espace de validation",4);

$f->displayHeader();

echo "
<script type=\"text/javascript\">
	dialogueAnime();
	dialogueAnimeBis();
	dialogueAnimeCom();
</script>
";

$res = mysql_query("SELECT * FROM Utilisateur WHERE  statut = 0 ;");

$res2 = mysql_query("SELECT * FROM Texte WHERE  statut = 0 ;");

$res5 = mysql_query("SELECT * FROM Commentaire WHERE  statut = 0 ;");

$nb_lignes = mysql_num_rows($res) + mysql_num_rows($res2) + mysql_num_rows($res5);

if ($nb_lignes == 0) {
	echo "<div class=\"center\">
		".BMInfo("Note: Il n'y a aucune demande en attente de validation",false)."
		</div>
	";
}
else {

$nb_lignes = mysql_num_rows($res);

if($nb_lignes != 0) {
	
	if($nb_lignes == 1) {
		echo "<p id=\"un\" class=\"titre_tab_query\">Le compte</p>";
	}
	else {
		echo "<p id=\"un\" class=\"titre_tab_query\">Les comptes</p>";
	}
	
	echo "<table id=\"data\" class=\"tab-tab\">
		<tr class=\"ui-tabs-nav ui-accordion ui-state-default tab-title\">
			<th>Pseudo</th>
			<th>Nom</th>
			<th>Prénom</th>
			<th>Valider</th>
			<th>Refuser</th>
		</tr>
		";

	while($row = mysql_fetch_array($res)) {
		echo "<tr class=\"tab-data\" >
			<td>".$row["pseudo"]."</td> 
			<td>".$row["nom"]."</td>
			<td>".$row["prenom"]."</td>
			<td>
				<a href =\"#un\" id=\"validUser\" onclick=\"init_validation(event)\"><img id=\"".$row['id']."\" src=\"../images/valider.png\"  alt=\"Valider\" title=\"Valider ce compte\"/></a>
			</td>
			<td>
				<a href =\"#un\" id=\"refusUser\" onclick=\"init_validation(event)\"><img id=\"".$row['id']."\" src=\"../images/supprimer.png\"  alt=\"Refuser\" title=\"Refuser ce compte\"/></a>
			</td>
		</tr>";
	}
	
	echo "</table>";

}

$nb_lignes = mysql_num_rows($res2);

if($nb_lignes != 0) {
	
	if($nb_lignes == 1) {
		echo "<p id=\"deux\" class=\"titre_tab_query\">Le texte</p>";
	}
	else {
		echo "<p id=\"deux\" class=\"titre_tab_query\">Les textes</p>";
	}
	
	echo "<table id=\"data\" class=\"tab-tab\">
		<tr class=\"ui-tabs-nav ui-accordion ui-state-default tab-title\">
			<th>Pseudo</th>
			<th>Titre</th>
			<th>Auteur</th>
			<th>Texte</th>
			<th>Valider</th>
			<th>Refuser</th>
		</tr>
		";
		
	$limite = 1;

	while($row = mysql_fetch_array($res2)) {
		
		if ($limite <= 5) {
		
		echo "<tr class=\"tab-data\" >";
		
		$res3 = mysql_query("SELECT idUser FROM PubliUserTexte WHERE  idTexte = ".$row['id'].";");
		
		while($row3 = mysql_fetch_array($res3)) {
			
			$res4 = mysql_query("SELECT pseudo FROM Utilisateur WHERE  id = ".$row3["idUser"].";");
			
			while($row4 = mysql_fetch_array($res4)) {
				echo "<td>".$row4["pseudo"]."</td>";
			}
		}
		
		echo "<td>".$row["titre"]."</td> 
			<td>".$row["auteur"]."</td>
			<td>
				
				<div id=\"dialog".s($limite)."\" title=\"".$row["auteur"]." : ".$row["titre"]."\">
					<p>".$row["contenu"]."</p>
				</div>
				
				<a href =\"#\" id=\"opener".s($limite)."\"><img src=\"../images/afficher.png\" alt=\"Afficher\" title=\"Afficher ce texte\"/></a>
			
			</td>
			<td>
				<a href =\"#deux\" id=\"validText\" onclick=\"init_validation(event)\"><img id=\"".$row['id']."\" src=\"../images/valider.png\"  alt=\"Valider\" title=\"Valider ce texte\"/></a>
			</td>
			<td>
				<a href =\"#deux\" id=\"refusText\" onclick=\"init_validation(event)\"><img id=\"".$row['id']."\" src=\"../images/supprimer.png\"  alt=\"Refuser\" title=\"Refuser ce texte\"/></a>
			</td>
		</tr>";
		
		$limite += 1;
		
		}
		
	}
	
	
	

echo "</table>";

}






$nb_lignes = mysql_num_rows($res5);

if($nb_lignes != 0) {
	
	if($nb_lignes == 1) {
		echo "<p id=\"trois\" class=\"titre_tab_query\">Le commentaire</p>";
	}
	else {
		echo "<p id=\"trois\" class=\"titre_tab_query\">Les commentaires</p>";
	}
	
	echo "<table id=\"data\" class=\"tab-tab\">
		<tr class=\"ui-tabs-nav ui-accordion ui-state-default tab-title\">
			<th>Date</th>
			<th>Auteur</th>
			<th>Commentaire</th>
			<th>Texte</th>
			<th>Valider</th>
			<th>Refuser</th>
		</tr>
		";
	
	$limite = 1;
	
	while($row = mysql_fetch_array($res5)) {
		echo "<tr class=\"tab-data\" >
			<td>".$row["date"]."</td> 
			<td>".$row["auteur"]."</td>";
			
		echo "<td>
				
				<div id=\"dialog2".s($limite)."\" title=\"".$row["auteur"]."\">
					<p>".$row["contenu"]."</p>
				</div>
				
				<a href =\"#\" id=\"opener2".s($limite)."\"><img src=\"../images/afficher.png\" alt=\"Afficher\" title=\"Afficher ce commentaire\"/></a>
			
			</td>";	
		
		$res6 = mysql_query("SELECT * FROM Texte WHERE  id = ".$row["idTexte"]." ;");
		
		while($row6 = mysql_fetch_array($res6)) {
			echo "<td>
				
				<div id=\"dialog1".s($limite)."\" title=\"".$row6["auteur"]." : ".$row6["titre"]."\">
					<p>".$row6["contenu"]."</p>
				</div>
				
				<a href =\"#\" id=\"opener1".s($limite)."\"><img src=\"../images/afficher.png\" alt=\"Afficher\" title=\"Afficher ce texte\"/></a>
			
			</td>";
			
		}
			
			
		echo "<td>
				<a href =\"#trois\" id=\"validCom\" onclick=\"init_validation(event)\"><img id=\"".$row['id']."\" src=\"../images/valider.png\"  alt=\"Valider\" title=\"Valider ce compte\"/></a>
			</td>
			<td>
				<a href =\"#trois\" id=\"refusCom\" onclick=\"init_validation(event)\"><img id=\"".$row['id']."\" src=\"../images/supprimer.png\"  alt=\"Refuser\" title=\"Refuser ce commentaire\"/></a>
			</td>
		</tr>";
		
		$limite += 1;
	}
	
	echo "</table>";

}











}


$f->displayFooter();
?>